#!/usr/bin/python
# encoding:utf-8
# cosine 2011/3/11

"""cmdline test
"""

import sys
from kscomm.spider.start import Spider

def func(argv_dict):
	print argv_dict['url'],argv_dict['deep']

	
if __name__ == '__main__':
	
	if len(sys.argv) <2:
		print 'usage: python test_cmd.py [site] [depth]\n\
		eg: python test_cmd.py http://www.knownsec.com 2'
		sys.exit()
	site = sys.argv[1]
	if not site.startswith(('http://','https://')):
		site = 'http://' + site
	deep = sys.argv[2]
	s = Spider(site,deep=int(deep),thread_num=5,crawl_scope=1,url_scope=1,url_type=1,crawl_tags=[],url_tags=['a'])
	s.set_callback(func,['url','deep'])
	s.start()
	s.get_time_statistic()
